
import { mapGetters } from 'vuex'
export default {
  data() {
    let api = null
    let path = this.$route && this.$route.path
    if (path) {
      try {
        api = require(`@/api${path}`)
      } catch (e) {
        try {
          path = path.substring(0, path.lastIndexOf('/'))
          api = require(`@/api${path}`)
        } catch (e) {
          // console.error(e.statusText)
        }
      }
    }
    return {
      api: api,
      /**
       * 当前路由路径
       */
      currentPath: path
    }
  },
  computed: {
    ...mapGetters(['user'])
  },
  methods: {
    triggerMethod(methodName) {
      let args = []
      if (arguments.length > 1) {
        args = Array.prototype.slice.call(arguments, 1)
      }
      this[methodName].apply(this, args)
      return this
    },
    setValue(name, value) {
      this[name] = value
      return this
    },
    getValue(name) {
      return this[name]
    }
  },
  watch: {
  },
  mounted() {

  }
}
